GBML manual / Events

draw_gui

Runs every frame, fixed to the screen - for a HUD. Everything drawn in it (draw_text, draw_sprite, draw_rect_fill, any draw call, even one made from a script it calls) is on the screen layer: it counts from the screen’s top-left pixel, never scrolls with the camera, and sits on top of the room, the shroud and every sprite in the world.

Syntax

draw_gui: fires every frame, fixed to the screen

Description

Runs every frame, fixed to the screen - it does not scroll with the camera the way Draw and the rest of world-space drawing do, which is what makes it the right place for a HUD: health, ammo, a counter, anything that should stay pinned to the same screen position regardless of where the camera is looking.

This event draws on a layer of its own: the screen layer. Think of it as a sheet of glass stuck to the screen, on top of everything else. Every draw call you make here - draw_text, draw_sprite, draw_rect_fill, draw_rect, the warped and 3D text calls, all of them - lands on that sheet, with no special name to remember:

The same call in a Draw event is a world draw instead: it scrolls with the camera and (x, y) is a place in the room. To put something on the screen from anywhere else (a Step event, say) use an _anchored call, such as draw_text_anchored: it also lets you count from a corner or the middle of the screen instead of the top-left pixel.

Example

draw_text(4, 4, "HP");

Draws a label pinned to the screen's top-left corner (in a Draw GUI event (0, 0) is the screen's top-left pixel, so (4, 4) is 4 pixels in and 4 down), unaffected by camera movement - the start of a HUD.

See also: draw_textdraw_spritedraw_rect_filldraw_text_anchoreddrawbg_prioritydepthEvents